//
//  DetailHeaderView.m
//  兼职页面
//
//  Created by kuiyuan liang on 2021/5/26.
//

#import "DetailHeaderView.h"
#import "PersonView.h"
#import "CommonUtil.h"
#import "FeedContentView.h"
@interface DetailHeaderView()
@property (strong, nonatomic) PersonView * infoView;
@property (strong, nonatomic) UIButton * reportBtn;
@property (strong, nonatomic) FeedContentView * feedView;

@property (strong, nonatomic) UIView * lineView;
@end

@implementation DetailHeaderView

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self addSubview:self.infoView];
        [self addSubview:self.reportBtn];
        [self addSubview:self.feedView];
        [self addSubview:self.lineView];
        self.reportBtn.centerY = self.infoView.centerY;
        self.reportBtn.right = SCREEN_WIDTH-AD(20);
    }
    return self;
}


-(void)layoutSubviews{
    [super layoutSubviews];
    
    self.lineView.bottom = self.feedView.bottom + AD(3);
}

-(void)setModel:(MessageModel *)model{
    _model = model;
    
    self.feedView.model = model;
    self.feedView.height = model.feedHeight;
    
    self.feedView.replayBtn.hidden = YES;
    self.feedView.reportBtn.hidden = YES;
  
    self.infoView.nameLabel.text = @"丝巾之一";
    self.infoView.iconImageView.image = [UIImage imageNamed:@"icon_redflower"];
    self.feedView.superVC = self.superVC;
}


- (void)reportBtnClick:(UIButton *)sender{
    NSLog(@"举报");
    BaseAlert *alert = [HudFactory creatHudWithType:@"ReportAlert"];
    [alert show];
}


#pragma mark - lazy
-(PersonView *)infoView{
    if (!_infoView) {
        _infoView = [[PersonView alloc] initWithFrame:CGRectMake(0, AD(20), SCREEN_WIDTH, AD(60))];
    }
    return _infoView;
}

-(FeedContentView *)feedView{
    if (!_feedView) {
        _feedView = [[FeedContentView alloc] initWithFrame:CGRectMake(0, _infoView.bottom, SCREEN_WIDTH, 0)];
    }
    return _feedView;
}


-(UIButton *)reportBtn{
    if (!_reportBtn) {
        _reportBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _reportBtn.frame = CGRectMake(0, 0, AD(80), AD(20));
        _reportBtn.titleLabel.font = [UIFont systemFontOfSize:AD(13)];
        [_reportBtn setTitle:@"举报" forState:UIControlStateNormal];
        [_reportBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [_reportBtn setImage:[UIImage imageNamed:@"icon_warning"] forState:UIControlStateNormal];
        _reportBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, -AD(10));
        [_reportBtn addTarget:self action:@selector(reportBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _reportBtn;
}

-(UIView *)lineView{
    if (!_lineView) {
        _lineView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, AD(1))];
        _lineView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    }
    return _lineView;
}
@end
